<?php
echo $this->render('resource/friendsite/_tab.phtml');
$this->render('include/sortLink.phtml');
$this->headScript()->appendFile(_STATIC_HTTP . '/jquery/checkAll.js');
if(!function_exists('__sortLink')) {
	function __sortLink() {}
}
?>
<?php $this->headStyle()->captureStart();?>
td.icon a {height:48px;background:#fff;border:1px solid #eee;}
<?php $this->headStyle()->captureEnd();?>
<form action="" method="post">
<div class="body">
	<table class="list">
		<tr>
			<th class="id"></th>
			<th class="narrow sort" title="<?php echo $this->language('Display Order');?>"><?php echo __sortLink('order', 'D');?></th>
			<th class="narrow sort"><?php echo __sortLink('click', 'CLICK');?></th>
			<th><?php echo $this->language('INFORMATION');?></th>
			<th class="time sort"><?php echo __sortLink('date', 'DATE');?></th>
			<th class="narrow center"><?php echo '<input type="checkbox" name="select-all" id="select-all" value="1" rel="id[]" />';?></th>
		</tr>
		<?php foreach($this->list AS $key => $row) { ?>
		<tr>
			<td class="icon"><a href="<?php echo $row->getLogo()->getLarge(false);?>" target="_blank"><img src="<?php echo $row->getLogo()->getSmall(false);?>" /></a></td>
			<td><?php
				if(!$row->getIsActive()) {
					echo '<em class="red">Invalid</em>';
				} else {
					echo $this->form()->text('display_order[' . $row->getId() . ']', $row->getDisplayOrder(), array('size' => '4', 'maxlength' => '8'));
					echo $this->form()->hidden('_display_order[' . $row->getId() . ']', $row->getDisplayOrder());
				}
			?></td>
			<td class="center"><h1><?php echo $row->getClick();?></h1></td>
			<td<?php if(!$row->getIsActive()) {echo ' class="gray"';}?>>
				<h3><a href="<?php echo $this->url('resource/friendsite/edit', array('id' => $row->getId()));?>"><?php echo $this->escape($row->getName());?></a></h3>
				<strong>Link</strong>: <a href="<?php echo $row->getUrl();?>" target="_blank"><?php echo $row->getUrl();?></a>
				<p class="toolbar">
					<a href="<?php echo $this->url('resource/friendsite/edit', array('id' => $row->getId()));?>"><?php echo $this->language('Edit');?>»</a>
				</p>
			</td>
			<td class="time"><?php echo $this->date($row->getCreationtime());?></td>
			<td class="center"><?php
			if($row->getIsActive()) {
				if(in_array($row->getId(), $this->checkedList)) {
					$checked = array('checked' => 'checked');
				} else {
					$checked = array();
				}
				echo $this->form()->checkbox('id[]', $row->getId(), array_merge(array('id' => 'id-' . $row->getId()), $checked));
			}
			?></td>
		</tr>
		<?php } ?>
		<?php if(count($this->list) <= 0) {?>
		<tr>
			<td colspan="6" class="nohover">
				<div class="msg">
					<div class="common error" style="border:0;background:#fff;">
						<i class="icon"></i>
						<h4>STOP</h4>
						<div class="msg-bd">
							No Friend SITE found. 
							<a href="<?php echo $this->url('resource/friendsite/addnew');?>"><?php echo $this->language('Create');?>..</a>
						</div>
					</div>
				</div>
			</td>
		</tr>
		<?php } ?>
	</table>
</div>
<div class="body">
	<div style="float:right;margin-bottom:5px;">
		<button type="reset" value="reset" onclick="return confirm('<?php echo $this->language('Reset all values you changed');?>?');"><?php echo $this->language('Reset');?></button>
		<button type="submit" name="saveChange" value="submit" onclick="return confirm('<?php echo $this->language('Are you sure to Save all changes');?>?');"><?php echo $this->language('Save Changes');?></button>
		<?php echo $this->render('include/deleteButton.phtml');?>
	</div>
	<?php echo $this->paginator($this->list)->render();?>
</div>
</form>